import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

import java.util.*;
import java.util.EventListener.*;
import java.text.*;
import java.io.*;
import java.rmi.*;

public class password extends JInternalFrame implements passwordInterface, ClientInterface
{
	private Container c;
	public String uname,pass,usname;
	public int ctr = 0;
	//public CheckBoxHandler handler = new CheckBoxHandler();
	public boolean rem;
	
	public password() 
    {
        
        super("UserRoll", 
              false, //resizable
              false, //closable
              false, //maximizable
              false);//iconifiable
		
		rem = false;
		c = getContentPane();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
       
 		int paintx = (screenSize.width);
		int painty = (screenSize.height);
		setBounds( 200,150,300,150);
				
		c.setLayout( null );
		
	user.setBounds( 20,15,80,20 );
        user.setForeground(Color.black);
        c.add( user );
        
      //  passwod.setBounds( 20,40,80,20 );
       // passwod.setForeground(Color.black);
       // c.add( passwod ); 
        
        usersName.setBounds( 20,40,120,20 );
        c.add( usersName );
        
       // userPassword.setBounds( 100,40,170,20 );
       // c.add( userPassword );
        
       	okButton.setBounds( 55,70,90,35 );
	c.add( okButton );
        
        closeButton.setBounds( 150,70,90,35 );
        c.add( closeButton );
        
        
        
        
        
        okButton.addActionListener( new ActionListener()
		{
			//dispose();		
 			public void actionPerformed(ActionEvent e) {
 				String usNa = usersName.getText();
 				if(usNa.equals(""))
 				JOptionPane.showMessageDialog(null,"User Roll set please","Information",JOptionPane.ERROR_MESSAGE);
 				else
 				{
 		try
			{
			String addServerUrl = "rmi://"+clientconf.getText()+"/MainServer" ;
			MainServerInterface se = (MainServerInterface)Naming.lookup(addServerUrl);
			
			String ra5 = se.ip_address(clientip.getText(),usNa,"Logged On");
			//if(ra5.equals("hollo")) 
			//{
				
					
			//}
			//System.out.println(ra5);
							
		}
		catch(Exception ex)
		{
			JOptionPane.showMessageDialog(null,"Cannot contact to the server","Information",JOptionPane.ERROR_MESSAGE);
		}
 		
 		exammenu.setEnabled(true);
 				dispose();
 				menuItem3.setEnabled(false);
 				menuItem6.setEnabled(true);
 				}
 				lab10.setText(usNa);
 				}
 			
 		});
        	
				
		closeButton.addActionListener( new ActionListener()
		{
			public void actionPerformed( ActionEvent e )
 			{			
 					
 					dispose(); 				
 			}
 		});
 		//dispose();
 		
 		
    }	
		
}
